package app.web.galgame.collect.netant;

import cn.lily.com.exception.YaconException;
import cn.lily.com.lang.Basic;
import cn.lily.com.lang.DeCode;
import cn.lily.web.page.BusinessPage;
import cn.lily.web.widget.sql.TSqlGrid;
import cn.lily.web.widget.standard.TButton;
import cn.lily.web.widget.standard.TButtonPilot;
/**
 * 忧郁的弟弟数据
 * @author JiaJ
 * @date 2018年6月16日
 *
 */
public class SadBrotherPage extends BusinessPage {

	@Override
	public void page_onLoad() throws YaconException {
		
		TSqlGrid sadBrotherGrid = sqlGrid("sadBrotherGrid");
		
		String gameNames = DeCode.decode(this.getAttr("gameName")).toUpperCase();
		String[] names = gameNames.split(",");
		String whereSQL = "";
		for(String name:names){
			whereSQL += " or UPPER(LEO_GAL_NAM) like '" + Basic.toWhereLike(name)+"'";
		}
		
		if(!"".equals(whereSQL)){
			whereSQL = whereSQL.substring(3);
		}
		
		sadBrotherGrid.setDictTable("LEO_SAD_BROTHER_INFO");
		String sqlString = "select * from ${schema}.LEO_SAD_BROTHER_INFO where "+whereSQL;
		sadBrotherGrid.setCommSqlStr(sqlString);
		sadBrotherGrid.setEdit(true);
			
		sadBrotherGrid.createFieldTitle("LEO_GAL_ID").setFieldVisible(false);
		sadBrotherGrid.createFieldTitle("LEO_GAL_NAM");
		sadBrotherGrid.createFieldTitle("LEO_GAL_MEMO").setFieldVisible(false);
		sadBrotherGrid.createFieldTitle("LEO_GAL_REMARK");
		sadBrotherGrid.createFieldTitle("LEO_GAL_STAFF");
		sadBrotherGrid.createFieldTitle("LEO_SITE_ANALYSE").setFieldVisible(false);

		TButtonPilot sadBrotherPilot = ButtonPilot("sadBrotherPilot");
		sadBrotherPilot.setPilotIco("/widget/buttonPilot.gif");
		sadBrotherPilot.setPilotText("忧郁的弟弟网站信息");
		
		TButton btn = new TButton("sadBrotherGrid_saveBtn");
		btn.setLabel("确定");
		btn.setIcoPath("glyphicon glyphicon-floppy-saved");
		btn.setViewClick("sadBrotherGrid_saveBtn_click");
		sadBrotherPilot.addButtons(btn);
		
		sadBrotherGrid.setButtonPilot(sadBrotherPilot);
		
		sadBrotherGrid.setTopButtonType("all");
		
		getPage().addElement(sadBrotherGrid);
		
	}
	
	public void refresh() throws YaconException {
		
		TSqlGrid sadBrotherGrid = sqlGrid("sadBrotherGrid");
		
		sadBrotherGrid.setDictTable("LEO_SAD_BROTHER_INFO");
		String sqlString = "select * from ${schema}.LEO_SAD_BROTHER_INFO ";
		sadBrotherGrid.setCommSqlStr(sqlString);
		
		this.setSelfMessage(sadBrotherGrid.getDataElement());
		
	}
	
	

}
